<!DOCTYPE html>
<!-- TODO: review -->
<?php
  if (preg_match('/^[http|https]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[#~A-Za-z0-9\.\/%&=\?\-_:\+]+$/i',$_GET['url'])) {
    $url = htmlentities($_GET['url']);
    $urlFwd = urlencode($_GET['url']);
  }
?>
<html lang="en">
  <meta charset="utf-8">
  <title>QA Scoring Dashboard</title>
  <body>
    <h1>TODO QA Scoring Dashboard</h1>
    <form action="./">
      <fieldset>
        <label>URL: <input type="text" name="url" value="<?php echo $url; ?>" autofocus></label> <input type="submit" value="Check">
      </fieldset>
    </form>
<?php if ($url != '') { ?>
    <h3>Scoring Matrix for <a href="http://www.google.com/url?sa=D&amp;q=<?php echo $urlFwd; ?>" target="_blank"><code><?php echo $url; ?></code></a> (<a href="./">clear</a>)</h3>
    <table>
      <tr>
        <th scope="col">Focus area and documentation
        <th colspan="2" scope="col">Tool and score
      <tr>
        <th scope="row">Accessibility
        <td colspan="2"><a href="http://www.sidar.org/hera/index.php.en?url=<?php echo $urlFwd; ?>" target="_blank">n/a</a> (perform analysis) <em>(external URLs only)</em>
      <!-- <tr>
        <th scope="row">UI compliance and consistency
        <td colspan="2"><a href="#TODO" target="_blank">n/a</a> (use bookmarklet on test page) -->
<?php
  $urlTypography = 'TODO?url=' . $urlFwd;
  $curl_handle = curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,$urlTypography);
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($curl_handle,CURLOPT_REFERER,'');
  curl_setopt($curl_handle,CURLOPT_USERAGENT,'');
  $bufferTypography = curl_exec($curl_handle);
  curl_close($curl_handle);
?>
      <tr>
        <th scope="row">Typography
        <!-- TODO -->
        <td colspan="2"><strong><?php echo (int)$bufferTypography; ?></strong> <em>(external URLs only)</em>
      <tr>
        <th scope="row">Links
        <td colspan="2"><a href="TODO/w3c-checklink/?uri=<?php echo $urlFwd; ?>&amp;hide_type=all&amp;depth=&amp;check=Check" target="_blank">n/a</a> (perform analysis)
<?php
  $urlPerformance = 'TODO/performance/?url=' . $urlFwd;
  $curl_handle = curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,$urlPerformance);
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($curl_handle,CURLOPT_REFERER,'');
  curl_setopt($curl_handle,CURLOPT_USERAGENT,'');
  $bufferPerformance = curl_exec($curl_handle);
  curl_close($curl_handle);
?>
      <tr>
        <th scope="row">Performance
        <td colspan="2"><a href="http://developers.google.com/speed/pagespeed/insights/?url=<?php echo $urlFwd; ?>" target="_blank"><strong><?php echo $bufferPerformance; ?></strong></a> <em>(external URLs only)</em>
<?php
  $urlMaintainability = 'TODO/analyze?url=' . $urlFwd . '&output=simple';
  $curl_handle = curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,$urlMaintainability);
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($curl_handle,CURLOPT_REFERER,'');
  curl_setopt($curl_handle,CURLOPT_USERAGENT,'');
  $bufferMaintainability = trim(curl_exec($curl_handle));
  curl_close($curl_handle);
?>
      <tr>
        <th scope="row">Maintainability
        <!-- TODO -->
        <td colspan="2"><a href="TODO/analyze?url=<?php echo $urlFwd; ?>" target="_blank"><strong><?php echo $bufferMaintainability; ?></strong></a> <em>(external URLs only)</em>
      <tr>
        <th scope="row">Security
        <td colspan="2"><a href="#TODO" target="_blank">n/a</a> (create session for test page)
<?php
  $urlSemantics = 'TODO/semantics/check.php5?url=' . $urlFwd . '&raw=yes';
  $curl_handle = curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,$urlSemantics);
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($curl_handle,CURLOPT_REFERER,'');
  curl_setopt($curl_handle,CURLOPT_USERAGENT,'');
  $bufferSemantics = curl_exec($curl_handle);
  curl_close($curl_handle);
?>
      <tr>
        <th scope="row">Semantics
        <td colspan="2"><a href="TODO/semantics/index.php5?url=<?php echo $urlFwd; ?>" target="_blank"><strong><?php echo $bufferSemantics; ?></strong></a>
<?php
  $urlValidation = 'TODO/validation/?url=' . $urlFwd;
  $curl_handle = curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,$urlValidation);
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($curl_handle,CURLOPT_REFERER,'');
  curl_setopt($curl_handle,CURLOPT_USERAGENT,'');
  $bufferValidation = curl_exec($curl_handle);
  curl_close($curl_handle);
?>
      <tr>
        <th rowspan="3" scope="col">Validation
        <td colspan="2"><a href="TODO/validation/?url=<?php echo $urlFwd; ?>" target="_blank"><strong><?php echo $bufferValidation; ?></strong></a>
<?php
  $urlValidationHtml = 'TODO/validation/html/?url=' . $urlFwd . '&raw=yes';
  $curl_handle = curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,$urlValidationHtml);
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($curl_handle,CURLOPT_REFERER,'');
  curl_setopt($curl_handle,CURLOPT_USERAGENT,'');
  $bufferValidationHtml = curl_exec($curl_handle);
  curl_close($curl_handle);
?>
      <tr>
        <th scope="row">HTML
        <td><a href="TODO/w3c-validator/check?uri=<?php echo $urlFwd; ?>" target="_blank"><?php echo $bufferValidationHtml; ?> errors</a>
<?php
  $urlValidationCss = 'TODO/validation/css/?url=' . $urlFwd . '&raw=yes';
  $curl_handle = curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,$urlValidationCss);
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($curl_handle,CURLOPT_REFERER,'');
  curl_setopt($curl_handle,CURLOPT_USERAGENT,'');
  $bufferValidationCss = curl_exec($curl_handle);
  curl_close($curl_handle);
?>
      <tr>
        <th scope="row">CSS
        <td><a href="TODO/css-validator/validator?uri=<?php echo $urlFwd; ?>&amp;profile=css3&amp;usermedium=all&amp;warning=1&amp;lang=en" target="_blank"><?php echo $bufferValidationCss; ?> errors</a>
      <!-- <tr>
        <th scope="row">Sum (<b>not</b> QA score)
        <td colspan="2"><?php echo ((int)$bufferTypography + (int)$bufferPerformance + (int)$bufferMaintainability + (int)$bufferSemantics + (int)$bufferValidation); ?> -->
    </table>
    <p>Enter data in the <a href="#TODO" target="_blank">QA scores spreadsheet</a> or <a href="./">test another page</a>. Olé.
<?php } ?>